#include "joystick.h"

SDL_Joystick* Joystick::joystick = NULL;

using namespace std;

Joystick::Joystick()
{
	Initialize();
}

Joystick::~Joystick()
{

}

void Joystick::Initialize()
{
	if (SDL_Init( SDL_INIT_VIDEO | SDL_INIT_JOYSTICK ) < 0)
	{
		fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
		exit(1);
	}
 	printf("%i joysticks were found.\n\n", SDL_NumJoysticks() );
 	printf("The names of the joysticks are:\n");
	for(int i=0; i < SDL_NumJoysticks(); i++ )
	{
		printf("	 %s\n", SDL_JoystickName(i));
	}

	SDL_JoystickEventState(SDL_ENABLE);
	joystick = SDL_JoystickOpen(0);
}

